// 引入axios
import axios from "axios"
const instance=axios.create({
    baseURL:" http://192.168.113.249:8081/cms"
})

// Add a request interceptor
instance.interceptors.request.use(function (config) {
    // Do something before request is sent
    console.log("请求");
    return config;
  }, function (error) {
    // Do something with request error
    return Promise.reject(error);
  });

// Add a response interceptor
instance.interceptors.response.use(function (response) {
    // Do something with response data
    console.log("响应");

    // 统一提示错误信息 
    if(response.data.code != 0){
      alert(response.data.message);
      return  //函数返回undefined
    }

    return response.data; //统一携带data
  }, function (error) {
    // Do something with response error
    return Promise.reject(error);
  });


export default instance